package com.nowar.data.strategy;

import com.nowar.data.strategy.service.StrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: 谢无殇。
 * @Date : 2023-03-07 23:33
 */
@Component
public class StrategyManageService {
    @Autowired
    private List<StrategyService> strategyServices;

    public StrategyBaseResponse dispatcher(StrategyBaseRequest request) {
        for (StrategyService strategyService : strategyServices) {
            if (strategyService.isMatch(request.getStrategy())) {
                return strategyService.handler(request);
            }
        }
        return null;
    }
}
